﻿// CSmartPay.cpp : Implementation of CCSmartPay

#include "stdafx.h"
#include "CSmartPay.h"
#include "Activity.h"
#pragma comment (lib,"bot.lib")


HRESULT STDMETHODCALLTYPE CCSmartPay::QueryStatus( 
	/* [unique][in] */ __RPC__in_opt const GUID *pguidCmdGroup,
	/* [in] */ ULONG cCmds,
	/* [out][in][size_is] */ __RPC__inout_ecount_full(cCmds) OLECMD prgCmds[  ],
	/* [unique][out][in] */ __RPC__inout_opt OLECMDTEXT *pCmdText)
{
	if(cCmds == 1)
	{
		prgCmds[1].cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
	}

	return S_OK;
}

HRESULT STDMETHODCALLTYPE CCSmartPay::Exec( 
	/* [unique][in] */ __RPC__in_opt const GUID *pguidCmdGroup,
	/* [in] */ DWORD nCmdID,
	/* [in] */ DWORD nCmdexecopt,
	/* [unique][in] */ __RPC__in_opt VARIANT *pvaIn,
	/* [unique][out][in] */ __RPC__inout_opt VARIANT *pvaOut)
{
	//
	IUnknown* pUnknown = NULL;
	HRESULT hr = this->GetSite(IID_IUnknown, reinterpret_cast<void **>(&pUnknown));
	if(FAILED(hr) || !pUnknown)
		MessageBoxW(NULL, L"初始化错误：无法通过IObjectWithSite->GetSite得到IUnknown接口", L"错误", MB_OK | MB_ICONERROR);
	//
	CActivity::Current()->Run(pUnknown);
	
	return S_OK;
}
